// https://leetcode.cn/problems/remove-element/

#include <vector>
#include <iostream>

using namespace std;

class Solution {
public:
    int removeElement(vector<int>& nums, int val) {
		int len = nums.size();
		int slow = 0;
		int fast = 0;
		while(fast < len){
			if(nums[fast] == val){
				fast++;
			}else{
				nums[slow++] = nums[fast++];
			}
		}
		return slow;
    }
	
	void show(vector<int>& nums, int len){
		int i = 0;
		while(i < len){
			cout << nums[i++] << ",";
		}
		cout << endl;
	}
};

int main(){
	Solution so;
	vector<int> head = {1,10,2,9};
	int num = so.removeElement(head, 1);
	cout << num << endl;
	so.show(head, num);
	return 0;
}